package com.mihong.Initializer;

import java.util.concurrent.TimeUnit;

import com.mihong.decoder.Decoder;
import com.mihong.instance1.NettyClientHandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.timeout.IdleStateHandler;

/**
 * 
 * @Description:服务端业务逻辑
 * @date: 2019年2月27日
 */
public class ServerChannelInitializer extends ChannelInitializer<SocketChannel>{

	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		//日志
		ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
		//监测心跳
		ch.pipeline().addLast("ping", new IdleStateHandler(60, 20, 60 * 10, TimeUnit.SECONDS));
		//解码器
		ch.pipeline().addLast(new Decoder());
		ch.pipeline().addLast(new NettyClientHandler());
		

	}

}